package Test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-03-10
 * Time: 19:18
 */
public class main {

    public static int binarySearch(int[] arr ,int x){
        if (arr == null){
            return -1;
        }
        int right = arr.length - 1;
        int left = 0;
        int mid = 0;
        while (left <= right){
            mid = (right + left) / 2;
            if (arr[mid] > x){
                right = mid -1;
                continue;
            }
            if (arr[mid] < x){
                left = mid + 1;
                continue;
            }
            return mid;
        }
        return -1;
    }
    public static void main(String[] args) {
        int[] arr = {2,6,4,1};
        boolean ret = isThreeodd(arr);
        //System.out.println(Arrays.toString(arr1));
        System.out.println(ret);
    }
    public static boolean isThreeodd(int[] arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 == 1){
                sum++;
                if (sum == 3){
                    return true;
                }
            }else {
                sum = 0;
            }
        }
        return false;
    }

    public static int find(int[] arr){
        int most = arr[0];
        int flag = 1;
        for (int i = 1; i < arr.length; i++) {
            if(arr[i] == most){
                flag++;
            }else {
                flag--;
                if (flag == 0){
                    flag = 1;
                    most = arr[i];
                }
            }
        }
        return most;
    }

    public static  int findOnce(int[] arr){
        if (arr == null){
            return -1;
        }
        int ret = 0;
        for (int i = 0; i < arr.length; i++) {
            ret ^= arr[i];
        }
        return ret;
    }

    public static int[] findSum(int[] arr , int target){
        if (arr == null){
            return null;
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if (j == i){
                    continue;
                }
                if (arr[i] + arr[j] == target && arr[i] != arr[j]){
                    int[] retarr = {i,j};
                    return retarr;
                }
            }
        }
        int[] retarr = {-1,-1};
        return retarr;
    }

    public static void bubblingSorting(int[] arr){
        int flag = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                    flag++;
                }
            }
            if (flag == 0){
                break;
            }
        }
    }

    public static void main2(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        int right = arr.length - 1;
        int left = 0;
        while (left < right){
            if (arr[right] % 2 == 1 && arr[left] % 2 == 0){
                int tmp = arr[right];
                arr[right] = arr[left];
                arr[left] = tmp;
                right--;
                left++;
            }else if (arr[right] % 2 == 0){
                right--;
            }else if (arr[left] % 2 == 1){
                left++;
            }else {
                ;
            }
        }
        System.out.println(Arrays.toString(arr));

    }
    public static void main1(String[] args) {
        String str = "ffffvd";
        System.out.println(str.hashCode());
        str = str.replace('f','d');
        System.out.println(str.hashCode());
        Scanner scanner = new Scanner(System.in);
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(str);
        while (true){
            String ch = scanner.nextLine();
            stringBuilder.append(ch);
            break;
        }
        System.out.println(stringBuilder);

        char[] arr = str.toCharArray();
        arr[0] = 'd';
        str = new String(arr);
    }
}
